package middle;

public class Solution_165 {

    public int compareVersion(String version1, String version2) {
        String[] split1 = version1.split("\\.");
        String[] split2 = version2.split("\\.");
        int length = Math.min(split1.length, split2.length);
        for (int i = 0; i < length; i++) {
            int var1 = Integer.parseInt(split1[i]);
            int var2 = Integer.parseInt(split2[i]);
            if (var1 > var2) {
                return 1;
            } else if (var2 > var1) {
                return -1;
            }
        }
        if (split1.length == split2.length) {
            return 0;
        } else if (split1.length < split2.length) {
            for (int i = length; i < split2.length; i++) {
                int var = Integer.parseInt(split2[i]);
                if (var > 0) {
                    return -1;
                }
            }
            return 0;
        } else {
            for (int i = length; i < split1.length; i++) {
                int var = Integer.parseInt(split1[i]);
                if (var > 0) {
                    return 1;
                }
            }
            return 0;
        }
    }

    public static void main(String[] args) {
        Solution_165 model = new Solution_165();
        System.out.println(model.compareVersion("1.01", "1.001")); // 0
        System.out.println(model.compareVersion("1.0", "1.0.0")); // 0
        System.out.println(model.compareVersion("0.1", "1.1")); // -1
    }
}
